import json

def getLoginUser(text):
    pass
# 获取 post 信息
headers = {
    'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36',
    'X-Requested-With': 'XMLHttpRequest',
    'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'
}
def getPostData(session,url,data,argu):

    resPost = session.post(url=url, data=data,headers = headers).text #此处获取的是post过来的json数据

    return getError(json.loads(resPost),argu)


# 获取请求是否成功的信息
def getError(jsonData,argu):
    argus = {}
    argus["getLoginMessage"] = "---登陆成功---"
    argus["getOrderDataMessage"] = "---获取预定信息成功---"
    if jsonData["code"] == 0:
        pass
        # print(argus[argu])
    else:
        print("---登陆失败，失败信息为:{}---".format(jsonData["msg"]))
        return ""
        exit(0)
    return jsonData["data"]


# 处理传输过来的json数据
def dataProcess(allRoomMessage):
    # 初始化 未预定的 时间区间列表
    timeInterval = {
    }

    for room in allRoomMessage:
        roomTime = []  # 每次遍历新的room，将roomTime 存储成list形式，方便查找空闲房间
        for time in room["roomTime"]:
            roomTime.append(int(time['timeStatus']))
        room["roomTime"] = roomTime
        timeInterval[room["roomId"]] = room
    return timeInterval